package utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Tools {

    protected final static Logger logger = LoggerFactory.getLogger(Tools.class);

    public static void getUserYorN() {
        // 使用 System.in 创建 BufferedReader
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = "";
        do {
            logger.info("请输入 Y 或 N ：");
            // 从控制台读取一行数据，返回值字符串
            try {
                str = br.readLine();
            } catch (IOException e) {
                logger.error("读取 控制台输入失败 ！");
            }
        } while (!(str.equals("") || str.equals("y") || str.equals("n") || str.equals("Y") || str.equals("N")));

        if (str.equals("n") || str.equals("N")) {
            System.exit(0);
        }
    }

}
